Memory devices having a three-dimensional structure in which memory holes are formed in a stacked body produced by layering together a plurality of electrode films separated by insulating films and in which silicon bodies that function as channels are formed along the sidewalls of the memory holes with charge storage films disposed therebetween have been proposed. The electrode films function as control gates in the memory cells and are formed by filling a metal or the like into cavities formed in the stacked body by removing portions thereof. In such three-dimensional memory devices, when removing portions of the stacked body and replacing those portions with a metal or the like, if any openings are left remaining, the stacked body may warp and cause the electrode films to deform.